﻿@using SCMS.Resource
@model SCMS.UI.Models.ExpenseClaim
<br />
<div class="partialViewCard">
    <div class="partialViewCardHeader"><h3>@Resources.ExpenseClaim_LoadExpenseClaim_NewExpenseClaim</h3></div>
    <br />
    <table width="98%" align="center" cellpadding="0" class="cardTable">
        <tr>
            <th align="center" width="33.3%">
                @Resources.Global_String_RefNo
            </th>
            <th align="center" width="33.3%">
                @Resources.Global_String_Date
            </th>
            <th align="center" width="33.3%">
                @Resources.ExpenseClaim_LoadExpenseClaim_ClaimBy (@Resources.Global_String_Name)
            </th>
        </tr>
        <tr>
            <td align="center">
                @Model.EntityExpseRqst.RefNumber
            </td>
            <td align="center">
                @Model.EntityExpseRqst.RequestDate.ToString("dd/MM/yyyy")
            </td>
            <td align="center">
                @Model.EntityExpseRqst.Staff1.Person.FirstName &nbsp;
                @Model.EntityExpseRqst.Staff1.Person.OtherNames
            </td>
        </tr>
        <tr>
            <th align="center">
                @Resources.ExpenseClaim_LoadExpenseClaim_ExpenseCurrency
            </th>
            <th align="center">
                @Resources.ExpenseClaim_LoadExpenseClaim_TotalExpense
            </th>
            <th align="center">
                @Resources.ExpenseClaim_LoadExpenseClaim_ClaimBy (@Resources.Global_String_Title)
            </th>
        </tr>
        <tr>
            <td align="center">
                @Model.EntityExpseRqst.Currency.ShortName
            </td>
            <td align="center">
                @Model.EntityExpseRqst.TotalValue.ToString("#,##0.00")  
            </td>
            <td align="center">
                @Model.EntityExpseRqst.Staff1.Designation.Name
            </td>
        </tr>
    </table>
    <br />
    &nbsp;&nbsp;&nbsp;
    @Ajax.ActionLink(Resources.ExpenseClaim_LoadExpenseClaim_AddNewECFItem, "LoadExpseItem", new { ecfId = Model.EntityExpseRqst.Id, currId = Model.EntityExpseRqst.ExpenseCurrencyId }, new AjaxOptions
{
    OnBegin = string.Format("ShowDialogue('{0}')", Resources.ExpenseClaim_LoadExpenseClaim_AddNewECFItem),
    UpdateTargetId = "popup-page",
    LoadingElementId = "popup-loading",
    OnSuccess = "CenterPopup(); ClearForm();"
})
    <br />
    @if (Model.EcfItems.Count() > 0)
    {
        <h4 style="text-align: center;">@Resources.ExpenseClaim_LoadExpenseClaim_ExpenseClaimItems</h4>
        <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" style="border: 1px solid grey;
            border-collapse: collapse; padding: 5px; font-size: 12px;">
            <tr class="gridheader">
                <th rowspan="2">
                    @Resources.Global_String_Description
                </th>
                <th colspan="2">
                    @Resources.ExpenseClaim_LoadExpenseClaim_Coding
                </th>
                <th rowspan="2">
                    @Resources.Global_String_Amount
                </th>
                <th rowspan="2">
                    @Resources.Global_String_Manage
                </th>
            </tr>
            <tr class="gridheader">
                <th>
                    @Resources.Budget_CategoryList_ProjectNo
                </th>
                <th>
                    @Resources.Budget_CreateSubLine_LineNumber
                </th>
            </tr>
            @foreach (var item in Model.EcfItems)
            {
                <tr class="gridodd">
                    <td>
                        @item.EntityExpseItem.ItemDescription
                    </td>
                    <td align="center">
                        @item.EntityExpseItem.ProjectBudget.BudgetCategory.ProjectDonor.ProjectNumber
                    </td>
                    <td align="center" title="@item.EntityExpseItem.ProjectBudget.Description">
                        @item.EntityExpseItem.ProjectBudget.LineNumber
                    </td>
                    <td align="right">
                        @item.EntityExpseItem.ItemAmount.ToString("##,##0.00")
                    </td>
                    <td align="center">
                        @Ajax.ActionLink(Resources.Global_String_Edit, "EditItem", new AjaxOptions
                   {
                       OnBegin = string.Format("ShowDialogue('{0} :: " + item.EntityExpseItem.ItemDescription + "')", Resources.Global_String_Edit),
                       UpdateTargetId = "popup-page",
                       LoadingElementId = "popup-loading",
                       Url = Url.Action("EditItem/" + item.EntityExpseItem.Id),
                       OnSuccess = "CenterPopup"
                   }) &nbsp;|&nbsp;
                        @Ajax.ActionLink(Resources.Global_String_Remove, "RemoveItem", new AjaxOptions
                   {
                       UpdateTargetId = "expenseclaimDiv",
                       LoadingElementId = "loading",
                       Url = Url.Action("RemoveItem/" + item.EntityExpseItem.Id),
                       Confirm = Resources.ExpenseClaim_LoadExpenseClaimItem_ConfirmDelete
                   })
                    </td>
                </tr>
            }
        </table>
        if (Model.BudgetCheckResults != null && Model.BudgetCheckResults.Count > 0)
        {
        <br />
        <center style="text-align: center; color: Red; font-weight: bold; font-style: italic;">@Resources_frank.ExpenseClaim_LoadECFItems_FundsUnavailableMessage</center>
        <table align="center" class="cardTable">
            <tr>
                <th>@Resources.Budget_CategoryList_ProjectNo</th>
                <th>@Resources.Budget_CreateSubLine_LineNumber</th>
                <th>@Resources.MasterBudget_MasterBudget_FundsAvailable</th>
                <th>@Resources_frank.OrderRequest_ViewOrderRequestItem_AmountChecked</th>
            </tr>
            @foreach (var bcr in Model.BudgetCheckResults)
            {
                <tr>
                    <td>@bcr.ProjectBudget.BudgetCategory.ProjectDonor.ProjectNumber</td>
                    <td>@bcr.ProjectBudget.LineNumber @bcr.ProjectBudget.Description</td>
                    <td style="color: Red; font-weight: bold;" align="right">@bcr.AvailableAmount.ToString("#,##0.00")</td>
                    <td align="right">@bcr.AmountChecked.ToString("#,##0.00")</td>
                </tr>
            }
        </table>
        }
        <br />
        <input type="hidden" id="actionStatus" value="@ViewBag.Response" />
        <input type="hidden" id="statusMsg" value="@ViewBag.msg" />
    
        <table align="center" width="98%">
            <tr>
                <td width="50%">
                    <input type="button" class="btn green" value="@Resources.Global_String_Previous" onclick="sendRequest('/ExpenseClaim/EditECF/@Model.EntityExpseRqst.Id', 'expenseclaimDiv', 'loading');" />
                </td>
                <td width="50%" align="right">
                    <input type="button" class="btn green" value="@Resources.Global_String_SubmitForReview" onclick="sendRequest('/ExpenseClaim/SubmitECF/@Model.EntityExpseRqst.Id', 'expenseclaimDiv', 'loading'); if (document.getElementById('table') != null) {initSorter();sorter.size(50);}" />
                </td>
            </tr>
        </table>    
    }    
    <br />
</div>
